package com.lsa.letcode.the29.divide;

import org.junit.Assert;
import org.junit.Test;

public class DivideTest {
	@Test
	public void test() {
		Solution s = new Solution();
		test(s, 32, 32);
		test(s, 32, 4);
		test(s, 16, 8);
		test(s, 100, 25);
		test(s, 121, 11);
		test(s, -121, -11);
		test(s, 121, -11);
		test(s, -121, 11);
		test(s, 17*19, 19);
		test(s, 1812*1905, 1812);
		
		test(s, Integer.MAX_VALUE, Integer.MAX_VALUE / 2);
		test(s, Integer.MIN_VALUE, -1, Integer.MAX_VALUE);
		test(s, Integer.MAX_VALUE, 1);
		test(s, Integer.MIN_VALUE / 2, 2);
	}

	private void test(Solution s, int dividend, int divisor) {
		test(s, dividend, divisor, dividend / divisor);
	}
	
	private void test(Solution s, int dividend, int divisor, int expected) {
		Assert.assertEquals(expected, s.divide(dividend, divisor));
	}
}